import React from 'react';
import SimpleTable from 'src/pages/AnalyseManage/EditReport/components/ChartsType/Table/SimpleTable';
import Text from 'src/pages/AnalyseManage/EditReport/components/ChartsType/Text';
import Pie from 'src/pages/AnalyseManage/EditReport/components/ChartsType/Pie';
import Filter from 'src/pages/AnalyseManage/EditReport/components/ChartsType//Filter';
import LiquidChart from 'src/pages/AnalyseManage/EditReport/components/ChartsType//Liquid';
import QuotaChart from 'src/pages/AnalyseManage/EditReport/components/ChartsType//Quota';
import ColumnChart from 'src/pages/AnalyseManage/EditReport/components/ChartsType//Column';
import ColumnLineChart from 'src/pages/AnalyseManage/EditReport/components/ChartsType//ColumnLine';
import GaugeChart from 'src/pages/AnalyseManage/EditReport/components/ChartsType//Gauge';
import LineChart from 'src/pages/AnalyseManage/EditReport/components/ChartsType//Line';
import DoubleYLineChart from 'src/pages/AnalyseManage/EditReport/components/ChartsType/DoubleYLine';
import AreaChart from 'src/pages/AnalyseManage/EditReport/components/ChartsType/Area';
import StackedColumn from 'src/pages/AnalyseManage/EditReport/components/ChartsType/StackedColumn';
import Scatter from 'src/pages/AnalyseManage/EditReport/components/ChartsType/Scatter';
import WordCloud from 'src/pages/AnalyseManage/EditReport/components/ChartsType/WordCloud';
import RadarChart from 'src/pages/AnalyseManage/EditReport/components/ChartsType/Radar';
import MapFill from 'src/pages/AnalyseManage/EditReport/components/ChartsType/MapFill';
import MapBubble from 'src/pages/AnalyseManage/EditReport/components/ChartsType/MapBubble';
import Bullet from 'src/pages/AnalyseManage/EditReport/components/ChartsType/Bullet';
import ImageChart from 'src/pages/AnalyseManage/EditReport/components/ChartsType/Image';
import ErrorBoundary from 'src/pages/ErrorBoundary';

const ChartsTypeMap = ( type, props ) => {
	const map = {
		'Text': <Text { ...props }></Text>,
		'SimpleTable': <SimpleTable { ...props }></SimpleTable>,
		'CrossTable': <SimpleTable { ...props }></SimpleTable>,
		'Pie': <Pie { ...props }></Pie>,
		'Circle': <Pie { ...props }></Pie>,
		'SingleChoice': <Filter { ...props } ></Filter>,
		'MultipleChoice': <Filter { ...props } ></Filter>,
		'DataRange': <Filter { ...props }></Filter>,
		'DatePicker': <Filter { ...props }></Filter>,
		'DateRangePicker': <Filter { ...props }></Filter>,
		'Liquid': <LiquidChart { ...props }></LiquidChart>,
		'Quota': <QuotaChart { ...props }></QuotaChart>,
		'Column': <ColumnChart { ...props }></ColumnChart>,
		'ColumnLine': <ColumnLineChart { ...props }></ColumnLineChart>,
		'Gauge': <GaugeChart { ...props }></GaugeChart>,
		'Line': <LineChart { ...props }></LineChart>,
		'DoubleYLine': <DoubleYLineChart { ...props }></DoubleYLineChart>,
		'Area': <AreaChart { ...props }></AreaChart>,
		'StackedColumn': <StackedColumn { ...props }></StackedColumn>,
		'Scatter': <Scatter { ...props }></Scatter>,
		'WordCloud': <WordCloud { ...props }></WordCloud>,
		'RadarChart': <RadarChart { ...props }></RadarChart>,
		'MapFill': <MapFill { ...props }></MapFill>,
		'MapBubble': <MapBubble { ...props }></MapBubble>,
		'Bullet': <Bullet { ...props }></Bullet>,
		'Image': <ImageChart { ...props }></ImageChart>
	};

	const errorRender = (
		<h1 style={ { 'textAlign': 'center' } }>
			组件错误，请重试
		</h1>
	);

	return (
		<ErrorBoundary errorRender={ errorRender }>
			{
				map[ type ]
			}
		</ErrorBoundary>
	);
};

export default ChartsTypeMap;
